﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SlamCms.SharePoint.Migration
{
	public class MigratableContentTypeList : List<MigratableContentType>, IMigratable
    {
        public XElement ToXml()
        {
            XElement node = new XElement("ContentTypes");
            foreach (MigratableContentType ct in this)
            {
                node.Add(ct.ToXml());
            }
            return node;
        }

        public void FromXml(XElement element)
        {
            var contentTypesNode = element.Element("ContentTypes");
            if (contentTypesNode.HasElements)
            {
                foreach (XElement child in contentTypesNode.Elements())
                {
                    MigratableContentType ct = new MigratableContentType();
                    ct.FromXml(child);
                    this.Add(ct);
                }
            }
        }
    }
}
